<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
    <title>登录页</title>
    <link rel="stylesheet" href="common.css" />
    <link rel="stylesheet" href="logIn.css" />
  </head>
  <body>
    <div class="navigation">
      <!-- 头像 -->
      <img
        src="https://img1.baidu.com/it/u=4205447136,2730860147&fm=253&fmt=auto&app=138&f=JPEG?w=300&h=300"
        alt="未登录"
      />
      <div class="title">未登录</div>

      <div class="space"></div>

      <a href="blog_list.html">主页</a>
      <a href="blog_edit.html">写博客</a>
    </div>
    <!-- 登录页面 -->

    <div class="login-Container">
      <div class="dialog">
        <form action="login" method="post" target="_blank">
          <h3>登录</h3>
          <div class="row">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" />
          </div>
          <div class="row">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" />
          </div>
          <div class="r">
            <input type="submit" id="submit" value="登录" />
          </div>
        </form>
      </div>
    </div>
    <script>
      jQuery.ajax({
        type: "get",
        url: "login",
        success: function (body) {
          location.href = "blog_list.html";
          alert("欢迎" + body.username + "!");
        },
        error: function(body) {
          alert("登录失效!");
        }
      });
    </script>
  </body>
</html>
